void recursiveTestWithMemory(CUBE* cube, U32 recursion)
{

	if (recursion == 0) // Maximum Precision is reached, no further computation can be done.
	{
		currentError += FP_Cube(cube->a);
	}
	else
	{
		double t1;
		double t2;
		//Creating edges' middles
		FP_POINT p12;
			COPY(p12,cube->p);
			p12.x = cube->p.x + (cube->a>>1);
		FP_POINT p34;
			COPY(p34,p12);
			p34.y = cube->p.y + cube->a;
		FP_POINT p56;
			COPY(p56,p12);
			p56.z = cube->p.z + cube->a;
		FP_POINT p78;
			COPY(p78,p34);
			p78.z = cube->p.z + cube->a;

		FP_POINT p13;
			COPY(p13,cube->p);
			p13.y = cube->p.y + (cube->a>>1);
		FP_POINT p24;
			COPY(p24,p13);
			p24.x = cube->p.x + cube->a;
		FP_POINT p57;
			COPY(p57,p13);
			p57.z = cube->p.z + cube->a;
		FP_POINT p68;
			COPY(p68,p24);
			p68.z = cube->p.z + cube->a;

		FP_POINT p15;
			COPY(p15,cube->p);
			p15.z = cube->p.z + (cube->a>>1);
		FP_POINT p26;
			COPY(p26,p15);
			p26.x = cube->p.x + cube->a;
		FP_POINT p37;
			COPY(p37,p15);
			p37.y = cube->p.y + cube->a;
		FP_POINT p48;
			COPY(p48,p26);
			p48.y = cube->p.y + cube->a;

		t1 = MPI_Wtime();

		// Testing io for edges' middles
		BOOL io12 = testAdherenceFPPoint(&p12);
		BOOL io34 = testAdherenceFPPoint(&p34);
		BOOL io56 = testAdherenceFPPoint(&p56);
		BOOL io78 = testAdherenceFPPoint(&p78);

		BOOL io13 = testAdherenceFPPoint(&p13);
		BOOL io24 = testAdherenceFPPoint(&p24);
		BOOL io57 = testAdherenceFPPoint(&p57);
		BOOL io68 = testAdherenceFPPoint(&p68);

		BOOL io15 = testAdherenceFPPoint(&p15);
		BOOL io26 = testAdherenceFPPoint(&p26);
		BOOL io37 = testAdherenceFPPoint(&p37);
		BOOL io48 = testAdherenceFPPoint(&p48);

		t2 = MPI_Wtime();
		computeTime += (t2-t1);


		//Creating faces middles
		FP_POINT p1234;
			p1234.x = cube->p.x + (cube->a>>1);
			p1234.y = cube->p.y + (cube->a>>1);
			p1234.z = cube->p.z;
		FP_POINT p5678;
			COPY(p5678,p1234);
			p5678.z = cube->p.z + cube->a;
		FP_POINT p1256;
			p1256.x = cube->p.x + (cube->a>>1);
			p1256.y = cube->p.y;
			p1256.z = cube->p.z + (cube->a>>1);
		FP_POINT p3478;
			COPY(p3478,p1256);
			p3478.y = cube->p.y + cube->a;
		FP_POINT p1357;
			p1357.x = cube->p.x;
			p1357.y = cube->p.y + (cube->a>>1);
			p1357.z = cube->p.z + (cube->a>>1);
		FP_POINT p2468;
			COPY(p2468,p1357);
			p2468.x = cube->p.x + cube->a;

		t1 = MPI_Wtime();

		//Testing io for faces middles
		BOOL io1234 = testAdherenceFPPoint(&p1234);
		BOOL io5678 = testAdherenceFPPoint(&p5678);
		BOOL io1256 = testAdherenceFPPoint(&p1256);
		BOOL io3478 = testAdherenceFPPoint(&p3478);
		BOOL io1357 = testAdherenceFPPoint(&p1357);
		BOOL io2468 = testAdherenceFPPoint(&p2468);

		t2 = MPI_Wtime();
		computeTime += (t2-t1);

		//Creating center of cube
		FP_POINT c;
			c.x = cube->p.x + (cube->a>>1);
			c.y = cube->p.y + (cube->a>>1);
			c.z = cube->p.z + (cube->a>>1);

		//Testing io for center of cube
		BOOL ioc = testAdherenceFPPoint(&c);

		//Creating the placeholding CUBE for every sub_cube, the "a" element will stay unchanged
		CUBE sub_cube;
		sub_cube.a = (cube->a>>1);

		//Initializing io vertices counter
		U32 counter;

		//Affecting to sub_cube #1
		COPY(sub_cube.p,cube->p);
		sub_cube.io_vertices[0]=cube->io_vertices[0];
		sub_cube.io_vertices[1]=io12;
		sub_cube.io_vertices[2]=io13;
		sub_cube.io_vertices[3]=io1234;
		sub_cube.io_vertices[4]=io15;
		sub_cube.io_vertices[5]=io1256;
		sub_cube.io_vertices[6]=io1357;
		sub_cube.io_vertices[7]=ioc;

		//Testing sub_cube #1
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#1 -- Accepted\n");
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#1 -- Subdivized\n");
			recursiveTestWithMemory(&sub_cube,recursion-1);
		}
		else
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#1 -- Rejected\n");
		}

		//Affecting to sub_cube #2
		sub_cube.p.x += cube->a/2;
		sub_cube.io_vertices[0]=io12;
		sub_cube.io_vertices[1]=cube->io_vertices[1];
		sub_cube.io_vertices[2]=io1234;
		sub_cube.io_vertices[3]=io24;
		sub_cube.io_vertices[4]=io1256;
		sub_cube.io_vertices[5]=io26;
		sub_cube.io_vertices[6]=ioc;
		sub_cube.io_vertices[7]=io2468;

		//Testing sub_cube #2
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#2 -- Accepted\n");
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#2 -- Subdivized\n");
			recursiveTestWithMemory(&sub_cube,recursion-1);
		}
		else
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#2 -- Rejected\n");
		}
		//Affecting to sub_cube #3
		COPY(sub_cube.p,cube->p);
		sub_cube.p.y += cube->a/2;
		sub_cube.io_vertices[0]=io13;
		sub_cube.io_vertices[1]=io1234;
		sub_cube.io_vertices[2]=cube->io_vertices[2];
		sub_cube.io_vertices[3]=io34;
		sub_cube.io_vertices[4]=io1357;
		sub_cube.io_vertices[5]=ioc;
		sub_cube.io_vertices[6]=io37;
		sub_cube.io_vertices[7]=io3478;

		//Testing sub_cube #3
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#3 -- Accepted\n");
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#3 -- Subdivized\n");
			recursiveTestWithMemory(&sub_cube,recursion-1);
		}
		else
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#3 -- Rejected\n");
		}

		//Affecting to sub_cube #4
		sub_cube.p.x += cube->a/2;
		sub_cube.io_vertices[0]=io1234;
		sub_cube.io_vertices[1]=io24;
		sub_cube.io_vertices[2]=io34;
		sub_cube.io_vertices[3]=cube->io_vertices[3];
		sub_cube.io_vertices[4]=ioc;
		sub_cube.io_vertices[5]=io2468;
		sub_cube.io_vertices[6]=io3478;
		sub_cube.io_vertices[7]=io48;

		//Testing sub_cube #4
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#4 -- Accepted\n");
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#4 -- Subdivized\n");
			recursiveTestWithMemory(&sub_cube,recursion-1);
		}
		else
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#4 -- Rejected\n");
		}

		//Affecting to sub_cube #5
		COPY(sub_cube.p,cube->p);
		sub_cube.p.z += cube->a/2;
		sub_cube.io_vertices[0]=io15;
		sub_cube.io_vertices[1]=io1256;
		sub_cube.io_vertices[2]=io1357;
		sub_cube.io_vertices[3]=ioc;
		sub_cube.io_vertices[4]=cube->io_vertices[4];
		sub_cube.io_vertices[5]=io56;
		sub_cube.io_vertices[6]=io57;
		sub_cube.io_vertices[7]=io5678;

		//Testing sub_cube #5
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#5 -- Accepted\n");
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#5 -- Subdivized\n");
			recursiveTestWithMemory(&sub_cube,recursion-1);
		}
		else
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#5 -- Rejected\n");
		}

		//Affecting to sub_cube #6
		sub_cube.p.x += cube->a/2;
		sub_cube.io_vertices[0]=io1256;
		sub_cube.io_vertices[1]=io26;
		sub_cube.io_vertices[2]=ioc;
		sub_cube.io_vertices[3]=io2468;
		sub_cube.io_vertices[4]=io56;
		sub_cube.io_vertices[5]=cube->io_vertices[5];
		sub_cube.io_vertices[6]=io5678;
		sub_cube.io_vertices[7]=io68;

		//Testing sub_cube #6
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#6 -- Accepted\n");
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#6 -- Subdivized\n");
			recursiveTestWithMemory(&sub_cube,recursion-1);
		}
		else
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#6 -- Rejected\n");
		}

		//Affecting to sub_cube #7
		COPY(sub_cube.p,cube->p);
		sub_cube.p.y += cube->a/2;
		sub_cube.p.z += cube->a/2;
		sub_cube.io_vertices[0]=io1357;
		sub_cube.io_vertices[1]=ioc;
		sub_cube.io_vertices[2]=io37;
		sub_cube.io_vertices[3]=io3478;
		sub_cube.io_vertices[4]=io57;
		sub_cube.io_vertices[5]=io5678;
		sub_cube.io_vertices[6]=cube->io_vertices[6];
		sub_cube.io_vertices[7]=io78;

		//Testing sub_cube #7
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#7 -- Accepted\n");
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#7 -- Subdivized\n");
			recursiveTestWithMemory(&sub_cube,recursion-1);
		}
		else
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#7 -- Rejected\n");
		}


		//Affecting to sub_cube #8
		sub_cube.p.x += cube->a/2;
		sub_cube.io_vertices[0]=ioc;
		sub_cube.io_vertices[1]=io2468;
		sub_cube.io_vertices[2]=io3478;
		sub_cube.io_vertices[3]=io48;
		sub_cube.io_vertices[4]=io5678;
		sub_cube.io_vertices[5]=io68;
		sub_cube.io_vertices[6]=io78;
		sub_cube.io_vertices[7]=cube->io_vertices[7];

		//Testing sub_cube #8
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#8 -- Accepted\n");
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#8 -- Subdivized\n");
			recursiveTestWithMemory(&sub_cube,recursion-1);
		}
		else
		{
			//for(int i = 0 ; i<level;i++)
			//	printf("   ");
			//printf("Cube n#8 -- Rejected\n");
		}
	}
}

void preRecursiveTestWithMemory(CUBE* cube, U32 recursion)
{

	if (recursion == 0) // Maximum Precision is reached, no further computation can be done.
	{
		nbGeneratedCubes++;
		STOCK_append(cube);
	}
	else
	{
		//Creating edges' middles
		FP_POINT p12;
			COPY(p12,cube->p);
			p12.x = cube->p.x + (cube->a>>1);
		FP_POINT p34;
			COPY(p34,p12);
			p34.y = cube->p.y + cube->a;
		FP_POINT p56;
			COPY(p56,p12);
			p56.z = cube->p.z + cube->a;
		FP_POINT p78;
			COPY(p78,p34);
			p78.z = cube->p.z + cube->a;

		FP_POINT p13;
			COPY(p13,cube->p);
			p13.y = cube->p.y + (cube->a>>1);
		FP_POINT p24;
			COPY(p24,p13);
			p24.x = cube->p.x + cube->a;
		FP_POINT p57;
			COPY(p57,p13);
			p57.z = cube->p.z + cube->a;
		FP_POINT p68;
			COPY(p68,p24);
			p68.z = cube->p.z + cube->a;

		FP_POINT p15;
			COPY(p15,cube->p);
			p15.z = cube->p.z + (cube->a>>1);
		FP_POINT p26;
			COPY(p26,p15);
			p26.x = cube->p.x + cube->a;
		FP_POINT p37;
			COPY(p37,p15);
			p37.y = cube->p.y + cube->a;
		FP_POINT p48;
			COPY(p48,p26);
			p48.y = cube->p.y + cube->a;


		// Testing io for edges' middles
		BOOL io12 = testAdherenceFPPoint(&p12);
		BOOL io34 = testAdherenceFPPoint(&p34);
		BOOL io56 = testAdherenceFPPoint(&p56);
		BOOL io78 = testAdherenceFPPoint(&p78);

		BOOL io13 = testAdherenceFPPoint(&p13);
		BOOL io24 = testAdherenceFPPoint(&p24);
		BOOL io57 = testAdherenceFPPoint(&p57);
		BOOL io68 = testAdherenceFPPoint(&p68);

		BOOL io15 = testAdherenceFPPoint(&p15);
		BOOL io26 = testAdherenceFPPoint(&p26);
		BOOL io37 = testAdherenceFPPoint(&p37);
		BOOL io48 = testAdherenceFPPoint(&p48);



		//Creating faces middles
		FP_POINT p1234;
			p1234.x = cube->p.x + (cube->a>>1);
			p1234.y = cube->p.y + (cube->a>>1);
			p1234.z = cube->p.z;
		FP_POINT p5678;
			COPY(p5678,p1234);
			p5678.z = cube->p.z + cube->a;
		FP_POINT p1256;
			p1256.x = cube->p.x + (cube->a>>1);
			p1256.y = cube->p.y;
			p1256.z = cube->p.z + (cube->a>>1);
		FP_POINT p3478;
			COPY(p3478,p1256);
			p3478.y = cube->p.y + cube->a;
		FP_POINT p1357;
			p1357.x = cube->p.x;
			p1357.y = cube->p.y + (cube->a>>1);
			p1357.z = cube->p.z + (cube->a>>1);
		FP_POINT p2468;
			COPY(p2468,p1357);
			p2468.x = cube->p.x + cube->a;



		//Testing io for faces middles
		BOOL io1234 = testAdherenceFPPoint(&p1234);
		BOOL io5678 = testAdherenceFPPoint(&p5678);
		BOOL io1256 = testAdherenceFPPoint(&p1256);
		BOOL io3478 = testAdherenceFPPoint(&p3478);
		BOOL io1357 = testAdherenceFPPoint(&p1357);
		BOOL io2468 = testAdherenceFPPoint(&p2468);


		//Creating center of cube
		FP_POINT c;
			c.x = cube->p.x + (cube->a>>1);
			c.y = cube->p.y + (cube->a>>1);
			c.z = cube->p.z + (cube->a>>1);

		//Testing io for center of cube
		BOOL ioc = testAdherenceFPPoint(&c);

		//Creating the placeholding CUBE for every sub_cube, the "a" element will stay unchanged
		CUBE sub_cube;
		sub_cube.a = (cube->a>>1);

		//Initializing io vertices counter
		U32 counter;

		//Affecting to sub_cube #1
		COPY(sub_cube.p,cube->p);
		sub_cube.io_vertices[0]=cube->io_vertices[0];
		sub_cube.io_vertices[1]=io12;
		sub_cube.io_vertices[2]=io13;
		sub_cube.io_vertices[3]=io1234;
		sub_cube.io_vertices[4]=io15;
		sub_cube.io_vertices[5]=io1256;
		sub_cube.io_vertices[6]=io1357;
		sub_cube.io_vertices[7]=ioc;

		//Testing sub_cube #1
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			preRecursiveTestWithMemory(&sub_cube,recursion-1);
		}

		//Affecting to sub_cube #2
		sub_cube.p.x += cube->a/2;
		sub_cube.io_vertices[0]=io12;
		sub_cube.io_vertices[1]=cube->io_vertices[1];
		sub_cube.io_vertices[2]=io1234;
		sub_cube.io_vertices[3]=io24;
		sub_cube.io_vertices[4]=io1256;
		sub_cube.io_vertices[5]=io26;
		sub_cube.io_vertices[6]=ioc;
		sub_cube.io_vertices[7]=io2468;

		//Testing sub_cube #2
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			preRecursiveTestWithMemory(&sub_cube,recursion-1);
		}

		//Affecting to sub_cube #3
		COPY(sub_cube.p,cube->p);
		sub_cube.p.y += cube->a/2;
		sub_cube.io_vertices[0]=io13;
		sub_cube.io_vertices[1]=io1234;
		sub_cube.io_vertices[2]=cube->io_vertices[2];
		sub_cube.io_vertices[3]=io34;
		sub_cube.io_vertices[4]=io1357;
		sub_cube.io_vertices[5]=ioc;
		sub_cube.io_vertices[6]=io37;
		sub_cube.io_vertices[7]=io3478;

		//Testing sub_cube #3
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			preRecursiveTestWithMemory(&sub_cube,recursion-1);
		}

		//Affecting to sub_cube #4
		sub_cube.p.x += cube->a/2;
		sub_cube.io_vertices[0]=io1234;
		sub_cube.io_vertices[1]=io24;
		sub_cube.io_vertices[2]=io34;
		sub_cube.io_vertices[3]=cube->io_vertices[3];
		sub_cube.io_vertices[4]=ioc;
		sub_cube.io_vertices[5]=io2468;
		sub_cube.io_vertices[6]=io3478;
		sub_cube.io_vertices[7]=io48;

		//Testing sub_cube #4
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			preRecursiveTestWithMemory(&sub_cube,recursion-1);
		}

		//Affecting to sub_cube #5
		COPY(sub_cube.p,cube->p);
		sub_cube.p.z += cube->a/2;
		sub_cube.io_vertices[0]=io15;
		sub_cube.io_vertices[1]=io1256;
		sub_cube.io_vertices[2]=io1357;
		sub_cube.io_vertices[3]=ioc;
		sub_cube.io_vertices[4]=cube->io_vertices[4];
		sub_cube.io_vertices[5]=io56;
		sub_cube.io_vertices[6]=io57;
		sub_cube.io_vertices[7]=io5678;

		//Testing sub_cube #5
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			preRecursiveTestWithMemory(&sub_cube,recursion-1);
		}

		//Affecting to sub_cube #6
		sub_cube.p.x += cube->a/2;
		sub_cube.io_vertices[0]=io1256;
		sub_cube.io_vertices[1]=io26;
		sub_cube.io_vertices[2]=ioc;
		sub_cube.io_vertices[3]=io2468;
		sub_cube.io_vertices[4]=io56;
		sub_cube.io_vertices[5]=cube->io_vertices[5];
		sub_cube.io_vertices[6]=io5678;
		sub_cube.io_vertices[7]=io68;

		//Testing sub_cube #6
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			preRecursiveTestWithMemory(&sub_cube,recursion-1);
		}

		//Affecting to sub_cube #7
		COPY(sub_cube.p,cube->p);
		sub_cube.p.y += cube->a/2;
		sub_cube.p.z += cube->a/2;
		sub_cube.io_vertices[0]=io1357;
		sub_cube.io_vertices[1]=ioc;
		sub_cube.io_vertices[2]=io37;
		sub_cube.io_vertices[3]=io3478;
		sub_cube.io_vertices[4]=io57;
		sub_cube.io_vertices[5]=io5678;
		sub_cube.io_vertices[6]=cube->io_vertices[6];
		sub_cube.io_vertices[7]=io78;

		//Testing sub_cube #7
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			preRecursiveTestWithMemory(&sub_cube,recursion-1);
		}

		//Affecting to sub_cube #8
		sub_cube.p.x += cube->a/2;
		sub_cube.io_vertices[0]=ioc;
		sub_cube.io_vertices[1]=io2468;
		sub_cube.io_vertices[2]=io3478;
		sub_cube.io_vertices[3]=io48;
		sub_cube.io_vertices[4]=io5678;
		sub_cube.io_vertices[5]=io68;
		sub_cube.io_vertices[6]=io78;
		sub_cube.io_vertices[7]=cube->io_vertices[7];

		//Testing sub_cube #8
		counter = 0;
		for(int i = 0 ; i<8 ; i++)
		{
			counter = counter + sub_cube.io_vertices[i];
		}
		if(counter==8)
		{	
			currentSum += FP_Cube((cube->a>>1));
		}
		else if (counter!=0)
		{
			preRecursiveTestWithMemory(&sub_cube,recursion-1);
		}
	}
}
void runRecursiveWithMemory(U32 recursionLevel)
{
	//Initializing unknown points of the original cube
	FP_POINT p2468;
		p2468.x=FP_ONE;
		p2468.y=0;
		p2468.z=0;
	FP_POINT p1256;
		p1256.x=0;
		p1256.y=-FP_ONE;
		p1256.z=0;
	FP_POINT p5678;
		p5678.x=0;
		p5678.y=0;
		p5678.z=FP_ONE;
	FP_POINT p3478;
		p3478.x=0;
		p3478.y=FP_ONE;
		p3478.z=0;
	FP_POINT p1234;
		p1234.x=0;
		p1234.x=0;
		p1234.z=-FP_ONE;

	//Testing io for unknown points
	BOOL io2468 = testAdherenceFPPoint(&p2468);
	BOOL io1256 = testAdherenceFPPoint(&p1256);
	BOOL io5678 = testAdherenceFPPoint(&p5678);
	BOOL io3478 = testAdherenceFPPoint(&p3478);
	BOOL io1234 = testAdherenceFPPoint(&p1234);

	//Creating #1 sub cube to be computed
	CUBE seed1;
	seed1.a = FP_ONE;
	seed1.p.x=0;
	seed1.p.y=-FP_ONE;
	seed1.p.z=-FP_ONE;
	seed1.io_vertices[0]=0;
	seed1.io_vertices[1]=0;
	seed1.io_vertices[2]=io1234;
	seed1.io_vertices[3]=0;
	seed1.io_vertices[4]=io1256;
	seed1.io_vertices[5]=0;
	seed1.io_vertices[6]=1;
	seed1.io_vertices[7]=io2468;
	
	//Creating #2 sub cube to be computed
	CUBE seed2;
	seed2.a = FP_ONE;
	seed2.p.x=0;
	seed2.p.y=0;
	seed2.p.z=-FP_ONE;
	seed2.io_vertices[0]=io1234;
	seed2.io_vertices[1]=0;
	seed2.io_vertices[2]=0;
	seed2.io_vertices[3]=0;
	seed2.io_vertices[4]=1;
	seed2.io_vertices[5]=io2468;
	seed2.io_vertices[6]=io3478;
	seed2.io_vertices[7]=0;

	//Creating #3 sub cube to be computed
	CUBE seed3;
	seed3.a = FP_ONE;
	seed3.p.x=0;
	seed3.p.y=-FP_ONE;
	seed3.p.z=0;
	seed3.io_vertices[0]=io1256;
	seed3.io_vertices[1]=0;
	seed3.io_vertices[2]=1;
	seed3.io_vertices[3]=io2468;
	seed3.io_vertices[4]=0;
	seed3.io_vertices[5]=0;
	seed3.io_vertices[6]=io5678;
	seed3.io_vertices[7]=0;

	//Creating #4 sub cube to be computed
	CUBE seed4;
	seed4.a = FP_ONE;
	seed4.p.x=0;
	seed4.p.y=0;
	seed4.p.z=0;
	seed4.io_vertices[0]=1;
	seed4.io_vertices[1]=io2468;
	seed4.io_vertices[2]=io3478;
	seed4.io_vertices[3]=0;
	seed4.io_vertices[4]=io5678;
	seed4.io_vertices[5]=0;
	seed4.io_vertices[6]=0;
	seed4.io_vertices[7]=0;

	//Launching initial computation of sub cubes
	double t1 = MPI_Wtime();

	preRecursiveTestWithMemory(&seed1,recursionLevel);
	preRecursiveTestWithMemory(&seed2,recursionLevel);
	preRecursiveTestWithMemory(&seed3,recursionLevel);
	preRecursiveTestWithMemory(&seed4,recursionLevel);

	recursiveTime = (MPI_Wtime()-t1)-computeTime;
}


void recursiveTestNoMemory(FP x, FP y, FP z, FP a, U32 recursion)
{
	
	//Testing io for vertices
	double t1 = MPI_Wtime();

	U32 counter=	testAdherenceCoordinates(x,y,z)		+
					testAdherenceCoordinates(x+a,y,z)	+
					testAdherenceCoordinates(x,y+a,z)	+
					testAdherenceCoordinates(x+a,y+a,z) +
					testAdherenceCoordinates(x,y,z+a)	+
					testAdherenceCoordinates(x+a,y,z+a) +
					testAdherenceCoordinates(x,y+a,z+a) +
					testAdherenceCoordinates(x+a,y+a,z+a);

	computeTime += MPI_Wtime() - t1;
	

	//Filtering cube
	if(counter==8)
	{	
		currentSum += FP_Cube(a);
	}
	else if (counter!=0)
	{	
		if (recursion == 0) // Maximum Precision is reached, no further computation can be done.
		{
			currentError += FP_Cube(a);
		}
		else
		{
			//Recursive call on sub cubes
			recursiveTestNoMemory(x,y,z,a/2,recursion-1);
			recursiveTestNoMemory(x+a/2,y,z,a/2,recursion-1);
			recursiveTestNoMemory(x,y+a/2,z,a/2,recursion-1);
			recursiveTestNoMemory(x+a/2,y+a/2,z,a/2,recursion-1);
			recursiveTestNoMemory(x,y,z+a/2,a/2,recursion-1);
			recursiveTestNoMemory(x+a/2,y,z+a/2,a/2,recursion-1);
			recursiveTestNoMemory(x,y+a/2,z+a/2,a/2,recursion-1);
			recursiveTestNoMemory(x+a/2,y+a/2,z+a/2,a/2,recursion-1);
		}
	}
}



void preRecursiveTestNoMemory(FP x, FP y, FP z, FP a, U32 recursion)
{	
	{
		//Testing io for vertices
		U32 counter=	testAdherenceCoordinates(x,y,z)		+
						testAdherenceCoordinates(x+a,y,z)	+
						testAdherenceCoordinates(x,y+a,z)	+
						testAdherenceCoordinates(x+a,y+a,z) +
						testAdherenceCoordinates(x,y,z+a)	+
						testAdherenceCoordinates(x+a,y,z+a) +
						testAdherenceCoordinates(x,y+a,z+a) +
						testAdherenceCoordinates(x+a,y+a,z+a);

		//Filtering cube
		if(counter==8)
		{	
			currentSum += FP_Cube(a);
		}
		else if (counter!=0)
		{	
			if (recursion == 0) // Maximum Precision is reached, no further computation can be done.
			{
				nbGeneratedCubes++;
				SIMPLE_CUBE* tmp = (SIMPLE_CUBE*) STOCK_writeNext();
				STOCK_WriteIncrement();
				tmp->a=a;
				tmp->p.x=x;
				tmp->p.y=y;
				tmp->p.z=z;
			}
			else
			{
				//Recursive call on sub cubes
				preRecursiveTestNoMemory(x,y,z,a/2,recursion-1);
				preRecursiveTestNoMemory(x+a/2,y,z,a/2,recursion-1);
				preRecursiveTestNoMemory(x,y+a/2,z,a/2,recursion-1);
				preRecursiveTestNoMemory(x+a/2,y+a/2,z,a/2,recursion-1);
				preRecursiveTestNoMemory(x,y,z+a/2,a/2,recursion-1);
				preRecursiveTestNoMemory(x+a/2,y,z+a/2,a/2,recursion-1);
				preRecursiveTestNoMemory(x,y+a/2,z+a/2,a/2,recursion-1);
				preRecursiveTestNoMemory(x+a/2,y+a/2,z+a/2,a/2,recursion-1);
			}
		}

	}
}

void runRecursiveNoMemory(U32 recursionLevel)
{	
	//Calling on 4 initial sub cubes
	preRecursiveTestNoMemory(0,-FP_ONE,-FP_ONE,FP_ONE,recursionLevel);
	preRecursiveTestNoMemory(0,0,-FP_ONE,FP_ONE,recursionLevel);
	preRecursiveTestNoMemory(0,-FP_ONE,0,FP_ONE,recursionLevel);
	preRecursiveTestNoMemory(0,0,0,FP_ONE,recursionLevel);
}




